import { http } from "@/utils/http";
import type { ApiResponse } from "../../user";

const ORDER_BASE = "/seller/trade/order";

export interface OrderListRecord {
  id: number;
  order_no: string;
  status: number;
  product_amount: number;
  original_total_amount: number;
  buyer_remark?: string;
  seller_remark?: string;
  create_time?: string;
  update_time?: string;
  [key: string]: any;
}

export interface OrderListResponse {
  list: Array<OrderListRecord>;
  pagination: {
    total: number;
    page: number;
    page_size: number;
    current_page?: number;
    currentPage?: number;
    pageSize?: number;
  };
}

export type OrderListResult = ApiResponse<OrderListResponse>;
export type OrderDetailResult = ApiResponse<Record<string, any>>;

const orderApi = {
  fetch(params: Record<string, any>) {
    return http.request<OrderListResult>("get", ORDER_BASE, {
      params
    });
  },

  read(id: number | string) {
    return http.request<OrderDetailResult>("get", `${ORDER_BASE}/${id}`);
  }
};

export default orderApi;
